
#include "EmployeeAemDbSaverTest.h"
#include "../../../../DAO/Savers/EmployeeSavers/EmployeeAemSaver/EmployeeAemDbSaver.h"
#include "../../../../DAO/Finders/EmployeeFinders/EmployeeAemFinders/EmployeeAemDbFinder.h"
#include "../../../../Utilities/ConvertTypes/ConvertType.h"

CPPUNIT_TEST_SUITE_REGISTRATION(EmployeeAemDbSaverTest);


void EmployeeAemDbSaverTest::setUp(){
	aemSaver_ = new EmployeeAemDbSaver;
	SYMBOLS_ = new string("!@#$%^&*\\\"\(\(\',.?/;:}]{[|+=_-~`");
}
void EmployeeAemDbSaverTest::tearDown(){
	delete aemSaver_;
	delete SYMBOLS_;
}

void	EmployeeAemDbSaverTest::saveAem_CurrentAemPlusOne_ReturnTrue(){
	IEmployeeAemDbFinder *aemFinder = new EmployeeAemDbFinder;
	string *currentAem = aemFinder->getNextValidAem();
	bool result=aemSaver_->saveAem(currentAem);
	delete aemFinder;
	delete currentAem;
	CPPUNIT_ASSERT_MESSAGE("Should pass because aem is the next valid aem",true==result);
}

void	EmployeeAemDbSaverTest::saveAem_CurrentAemPlusTen_ReturnFalse(){
	IEmployeeAemDbFinder *aemFinder = new EmployeeAemDbFinder;
	string *currentAem = aemFinder->getNextValidAem();
	ConvertType *strConverter = new ConvertType;

	currentAem = strConverter->toString(10+strConverter->toInt(currentAem));
	bool result=aemSaver_->saveAem(currentAem);

	delete strConverter;
	delete aemFinder;
	delete currentAem;

	CPPUNIT_ASSERT_MESSAGE("Should fail because aem isn't the next valid aem",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_NegativeAem_ReturnFalse(){
	string *currentAem = new string("-125");
	bool result = aemSaver_->saveAem(currentAem);
	delete currentAem;
	CPPUNIT_ASSERT_MESSAGE("Should fail because aem is negative number",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_CharactersAsAem_ReturnFalse(){
	string *currentAem = new string("OneHundred");
	bool result = aemSaver_->saveAem(currentAem);
	delete currentAem;
	CPPUNIT_ASSERT_MESSAGE("Should fail because aem has characters",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_SybolsAsAem_ReturnFalse(){
	bool result = aemSaver_->saveAem(SYMBOLS_);
	CPPUNIT_ASSERT_MESSAGE("Should fail because aem has characters",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_SybolsAndCharactersAsAem_ReturnFalse(){
	string *currentAem = new string("OneHundred");
	*currentAem += *SYMBOLS_;
	bool result = aemSaver_->saveAem(currentAem);
	delete currentAem;
	CPPUNIT_ASSERT_MESSAGE("Should fail because aem has characters & symbols",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_NullAsAem_ReturnFalse(){
	bool result = aemSaver_->saveAem(NULL);
	CPPUNIT_ASSERT_MESSAGE("Should fail because aem is NULL",false==result);
}

void	EmployeeAemDbSaverTest::saveAem_PositiveNumberAsAem_ReturnTrue(){
	string *currentAem = new string("12345");
	bool result = aemSaver_->saveAem(currentAem);
	delete currentAem;
	CPPUNIT_ASSERT_MESSAGE("Should succeed because aem is positive number",true==result);
}
